package com.hwq.leetcode;

import org.junit.Test;

public class PrintRevers {
    @Test
    public void test(){

    }
    public int[] reversePrint(ListNode head) {
        //先遍历一遍，找出大小，然后申请一个对应大小的字符串
        ListNode temp = head;
        int num = 0;
        while(temp != null){
            num++;
            temp = temp.next;
        }
        temp = head;
        int[] result = new int[num];
        for(int i = 0; i < num ;i++){
            result[num - i - 1] = temp.val;
            temp = temp.next;
        }
        return result;
    }
}
